package cn.tsmchina.one.service.recommendation;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.tsmchina.one.dao.activity.ActivityDao;
import cn.tsmchina.one.dao.recommendation.RecommentDao;
import cn.tsmchina.one.dao.user.UserDao;
import cn.tsmchina.one.domain.activity.Activity;
import cn.tsmchina.one.domain.recommendation.Recommend;
import cn.tsmchina.one.domain.user.User;
import cn.tsmchina.one.pojo.ActivityPojo;
import cn.tsmchina.one.pojo.RecommendPojo;
import cn.tsmchina.one.util.C;

@Service
public class RecommentServiceImpl implements RecommentService
{
	@Autowired
	private RecommentDao recDao;
	
	@Autowired
	private UserDao userDao;
	
	@Override
	public Integer addRec(Recommend rec) {
		return recDao.addRec(rec);
	}
	
	@Override
	public List<RecommendPojo> getRecs(int page, long cid)
	{
		 List<Recommend> list = recDao.recs(page, cid);
		 System.out.println("after-----");
		 List<RecommendPojo> recPojos = new ArrayList<>();
		 for (Recommend rec : list)
			recPojos.add(new RecommendPojo(rec));
		 return recPojos;
	}
	
	@Override
	public void deleteRecById(int id) {
		recDao.deleteById(id);
		
	}
	
	@Override
	public Recommend getRec(int id)
	{
		return recDao.findRec(id);
	}

	@Override
	public int getTotal(long cid)
	{
		return recDao.total(cid);
	}

	@Override
	public List<Recommend> getRecNotice()
	{
		return recDao.getRecNotice();
	}

	@Override
	public void updateRec(Recommend rec) {
		recDao.updateRec(rec);
	}

	@Override
	public int getTotal() {
		// TODO Auto-generated method stub
		return recDao.getTotal();
	}
}
